package com.agung.wonogirimaps;

import com.agung.wonogirimaps.util.Utils;
import com.google.android.gms.maps.model.LatLng;
import com.nostra13.universalimageloader.core.ImageLoader;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

public class DetailRumahMakanActivity extends ActionBarActivity implements
		OnClickListener
{
	private TextView	nama, alamat, jenisMakanan;
	private ImageView	img;
	private ImageView	btnDirection;
	private LatLng		location;
	private ImageLoader	imageLoader;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_detail_rumah_makan);

		imageLoader = ImageLoader.getInstance();
		imageLoader.init(Utils.getImgConfig(this));

		nama = (TextView) findViewById(R.id.detail_nama_rumahmakan);
		alamat = (TextView) findViewById(R.id.detail_alamat_rumahmakan);
		img = (ImageView) findViewById(R.id.thumb_rumahmakan);
		btnDirection = (ImageView) findViewById(R.id.btn_direct_rumahmakan);
		jenisMakanan = (TextView) findViewById(R.id.detail_jenismakanan_rumahmakan);

		getSupportActionBar().setTitle("Detail Rumah Makan");
		getSupportActionBar().setIcon(android.R.color.transparent);

		Bundle b = getIntent().getExtras();
		if (b != null)
		{
			nama.setText(b.getString(RumahMakanActivity.TAG_NAMA));
			alamat.setText(b.getString(RumahMakanActivity.TAG_ALAMAT));
			location = new LatLng(b.getDouble(RumahMakanActivity.TAG_LAT),
					b.getDouble(RumahMakanActivity.TAG_LNG));
			jenisMakanan.setText(b.getString(RumahMakanActivity.TAG_MENU));
			imageLoader.displayImage(
					b.getString(RumahMakanActivity.TAG_GAMBAR), img,
					Utils.getImgOpt());
		}

		btnDirection.setOnClickListener(this);

	}

	@Override
	public void onClick(View v)
	{
		if (v == btnDirection)
		{
			Intent i = new Intent(android.content.Intent.ACTION_VIEW,
					Uri.parse("http://maps.google.com/maps?daddr="
							+ location.latitude + "," + location.longitude));
			startActivity(i);
		}

	}
}
